<template>
	<view style="height: 100vh; background-color: #FFFFFF;">
		<u-navbar title-color="#FFFFFF" height="48" back-icon-color="#FFFFFF" :border-bottom="false" :is-fixed="true" title="任务详情"></u-navbar>
		<uc-content :loading="loading">
			<view class="list-item">
				<view class="list-bottom">
					<view>任务名称:</view>
					<view>{{enterpriseTaskInfo.name}}</view>
				</view>
			</view>
			<view class="list-item">
				<view class="list-bottom">
					<view>负责区域:</view>
					<view>{{enterpriseTaskInfo.regionName}}</view>
				</view>
			</view>
			<view class="list-item">
				<view class="list-bottom">
					<view>任务描述:</view>
					<view>{{enterpriseTaskInfo.remark}}</view>
				</view>
			</view>
			<view class="list-item">
				<view class="list-bottom">
					<view>任务内容:</view>
					<view>{{enterpriseTaskInfo.content}}</view>
				</view>
			</view>
			<view class="list-item">
				<view class="list-bottom">
					<view>任务类型:</view>
					<view>{{enterpriseTaskInfo.type|type}}</view>
				</view>
			</view>
			<view class="list-item">
				<view class="list-bottom">
					<view>开始时间:</view>
					<view>{{enterpriseTaskInfo.startTime|taskDate}}</view>
				</view>
			</view>
			<view class="list-item">
				<view class="list-bottom">
					<view>结束时间:</view>
					<view>{{enterpriseTaskInfo.endTime|taskDate}}</view>
				</view>
			</view>
			<view>
				<u-button @click="receive(enterpriseTaskInfo.ucId)" type="primary" size="medium" style="width: 100%;" :disabled="enterpriseTaskInfo.status==1" >领取</u-button>
			</view>
		</uc-content>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				enterpriseTaskInfo: {},
                taskId:"",
				loading:false,
				show:false
			}
		},
		onLoad(e) {
			this.taskId = e.ucId
		},
		onShow(){
			this.initView(this.taskId)
		},
		methods: {
			initView(val) {
				this.loading = true
				this.enterpriseTaskInfo = {}
				this.pageNum = 0
				this.getInEnterpriseTaskVo(val)
			},
			getInEnterpriseTaskVo(val) {
				this.utils.request("/api/app/enterpriseTask/getInEnterpriseTaskVo", {	ucId: val}, "post", "app", true).then(res => {
					this.loading = false
					this.enterpriseTaskInfo = res.data
				}).catch(error => {
					this.loading = false
					console.log(error)
				})
			},
			receive(val) {
				this.utils.request("/api/app/task/taskReceive", {
					ucId: val
				}, "post", "app", true).then(res => {
					
					this.initView()
					// 点击确认后禁用按钮
				uni.navigateTo({
				    url: '/pages/index/task/list'
				});
				}).catch(error => {
					uni.showToast({
					    title: '任务已被领取',
					    duration: 1000,
						icon:"none",
					});
					
					
					console.log(error)
				})
			},
			
		}
	}
</script>

<style lang="scss" scoped>
	@import "../../../uview-ui/libs/css/style.components.scss";
	
	.list-item {
		padding: 20rpx 40rpx;
		background-color: #fff;
		border-bottom: #999999 1px dashed ;
	
		.list-bottom {
			display: flex;
			margin-top: 10rpx;
			font-size: 28rpx;
			justify-content: space-between;
			color: #333;
		}
		.list-center {
			margin-top: 20rpx;
			font-size: 28rpx;
			color: #999999;
		}
	}
</style>
